package com.ruoyi.web.controller.basedata;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.basedata.domain.ElectricityAreaZoneJoin;
import com.ruoyi.basedata.service.IElectricityAreaZoneJoinService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 分区关联-电、水关联Controller
 * 
 * @author gdqt
 * @date 2025-03-06
 */
@RestController
@RequestMapping("/basedata/join")
public class ElectricityAreaZoneJoinController extends BaseController
{
    @Autowired
    private IElectricityAreaZoneJoinService electricityAreaZoneJoinService;

    /**
     * 查询分区关联-电、水关联列表
     */
    @PreAuthorize("@ss.hasPermi('basedata:join:list')")
    @GetMapping("/list")
    public TableDataInfo list(ElectricityAreaZoneJoin electricityAreaZoneJoin)
    {
        startPage();
        List<ElectricityAreaZoneJoin> list = electricityAreaZoneJoinService.selectElectricityAreaZoneJoinList(electricityAreaZoneJoin);
        return getDataTable(list);
    }

    /**
     * 导出分区关联-电、水关联列表
     */
    @PreAuthorize("@ss.hasPermi('basedata:join:export')")
    @Log(title = "分区关联-电、水关联", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ElectricityAreaZoneJoin electricityAreaZoneJoin)
    {
        List<ElectricityAreaZoneJoin> list = electricityAreaZoneJoinService.selectElectricityAreaZoneJoinList(electricityAreaZoneJoin);
        ExcelUtil<ElectricityAreaZoneJoin> util = new ExcelUtil<ElectricityAreaZoneJoin>(ElectricityAreaZoneJoin.class);
        util.exportExcel(response, list, "分区关联-电、水关联数据");
    }

    /**
     * 获取分区关联-电、水关联详细信息
     */
    @PreAuthorize("@ss.hasPermi('basedata:join:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(electricityAreaZoneJoinService.selectElectricityAreaZoneJoinById(id));
    }

    /**
     * 新增分区关联-电、水关联
     */
    @PreAuthorize("@ss.hasPermi('basedata:join:add')")
    @Log(title = "分区关联-电、水关联", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ElectricityAreaZoneJoin electricityAreaZoneJoin)
    {
        return toAjax(electricityAreaZoneJoinService.insertElectricityAreaZoneJoin(electricityAreaZoneJoin));
    }

    /**
     * 修改分区关联-电、水关联
     */
    @PreAuthorize("@ss.hasPermi('basedata:join:edit')")
    @Log(title = "分区关联-电、水关联", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ElectricityAreaZoneJoin electricityAreaZoneJoin)
    {
        return toAjax(electricityAreaZoneJoinService.updateElectricityAreaZoneJoin(electricityAreaZoneJoin));
    }

    /**
     * 删除分区关联-电、水关联
     */
    @PreAuthorize("@ss.hasPermi('basedata:join:remove')")
    @Log(title = "分区关联-电、水关联", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(electricityAreaZoneJoinService.deleteElectricityAreaZoneJoinByIds(ids));
    }
}
